<template>
  <div class="mark" v-show="showTip" @click.self="closeTip">
    <div class="box">
      <p>{{ msg.text }}</p>
      <button @click="closeTip" v-show="msg.showCancel">取消</button>
      <button @click="del" v-show="msg.showSubmit">确认</button>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  computed: {
    ...mapState(["showTip", "msg"]),
  },
  methods: {
    ...mapMutations(["closeTip", "delGood"]),
    del() {
      if (this.msg.type === 2) {
        this.delGood();
        // 关闭提示
        this.closeTip();
      } else if (this.msg.type === 1) {
        // 关闭提示
        this.closeTip();
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.mark {
  background: rgba($color: #000000, $alpha: 0.5);
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  display: flex;

  .box {
    width: 400px;
    height: 300px;
    background: #ffffff;
    margin: auto;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    p {
      font-size: 30px;
      width: 100%;
    }

    button {
      width: 80px;
      height: 40px;
      border-radius: 4px;
      margin-left: 10px;

      &:active {
        background: #ccc;
      }
    }

    button:last-child {
      margin-left: auto;
      margin-right: 10px;
    }
  }
}
</style>
